package com.gt.quality.base.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @description: 通用请求
 * @author: makeJava
 * @since JDK21
 **/
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BaseLimitRequest<T> extends BasePage {

    /**
     * Description: 实体类
     */
    private T requestBody;


    /**
     * Description: 开始时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime beginTime;


    /**
     * Description: 结束时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;

    /**
     * 是否需要排序
     */
    private boolean needOrderBy;

    /**
     * 排序方式----1:代表升序| 2:代表倒序
     */
    private int orderByMethod;


    /**
     * 排序的字段|Lambda选用驼峰,非Lambda选用下划线
     */
    private String orderByKeyName;

    /**
     * 时间选择的字段|Lambda选用驼峰,非Lambda选用下划线
     */
    private String selectByTimeKeyName;

    /**
     * 自定义字段{
     * 字段名称:字段比较方式[EQ|Like]
     * }
     */
    private Map<String, String> excludeCol;

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.JSON_STYLE)
                .append("requestBody", requestBody)
                .append("beginTime", beginTime)
                .append("endTime", endTime)
                .append("needOrderBy", needOrderBy)
                .append("orderByMethod", orderByMethod)
                .append("orderByKeyName", orderByKeyName)
                .append("pageIndex", pageIndex)
                .append("pageSize", pageSize)
                .toString();
    }
}
